import React from 'react';
class App extends React.Component {
    state = {

    }
    render() {
        return (
            <div>
                <h1>反向代理跨域</h1>
                <button onClick={()=>{
                      let xhr = new XMLHttpRequest();
                      xhr.open("get","/douban/j/search_subjects?type=movie&tag=热门&page_limit=50&page_start=0");
                      // https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json?ct=郑州&ci=73&channelId=4
                      xhr.send();
                      xhr.onreadystatechange = ()=>{
                          if(xhr.readyState === 4){
                              console.log(JSON.parse(xhr.response))
                          }
                      }
                }}>请求豆瓣电影</button>
            </div>
        )
    }
    componentDidMount(){
        let xhr = new XMLHttpRequest();
        xhr.open("get","/maoyan/api/mmdb/movie/v3/list/hot.json?ct=郑州&ci=73&channelId=4");
        // https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json?ct=郑州&ci=73&channelId=4
        xhr.send();
        xhr.onreadystatechange = ()=>{
            if(xhr.readyState === 4){
                console.log(JSON.parse(xhr.response))
            }
        }
    }
}

export default App;